package com.example.himalayaproject.find.broadcast.activity;

import android.graphics.Bitmap;
import android.graphics.BitmapShader;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Shader;

import com.squareup.picasso.Transformation;

/**
 * Created by Administrator on 2016/12/9.
 */

public class RectTransformation implements Transformation {
    @Override
    public Bitmap transform(Bitmap source) {
        Bitmap target = Bitmap.createBitmap(source.getWidth(),source.getHeight(), Bitmap.Config.ARGB_8888);
        Paint paint = new Paint();
        paint.setStyle(Paint.Style.STROKE);
        paint.setShader(new BitmapShader(source, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP));
        new Canvas(target).drawRect(0,0,source.getWidth()*2,source.getHeight()*2,paint);
        source.recycle();
        return target;
    }

    @Override
    public String key() {
        return "Rect";
    }
}
